Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for forward and back mouse buttons #1919

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CendioHalim
Copy link

This commit implements the extendedMouseButtons pseudo-encoding, which makes it possible to use the forward and back mouse buttons.

It looks like chromium is the only browser that has support for this currently. See #1918 for more info.

Confirmed that it works with chromium on Mac, Linux and Windows against TigerVNC server.

@CendioHalim
Copy link
Author

This MR should partly fix #1920, but only on chromium.

core/rfb.js Outdated
Comment on lines 1067 to 1068
* NOTE: This only works on chromium-based browsers. There is
* no support for firefox/safari.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, Safari has buggy support rather than no support. Right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

I just realized that safari send the incorrect ev.button value, but the button mask ev.buttons seems to work correctly. With back pressed, ev.buttons is 8, and with forward pressed, it is 16.

We could look at those instead of keeping mouse button state ourselves?

it('should send correct data for extended pointer events', function () {
RFB.messages.extendedPointerEvent(sock, 12345, 54321, 0xab);
let expected =
[ 5, 0xab, 0x30, 0x39, 0xd4, 0x31, 0x01];
expect(sock).to.have.sent(new Uint8Array(expected));
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd also like tests for the interaction with the pseudo-encoding and pseudo-rect.

[ 5, 0xab, 0x30, 0x39, 0xd4, 0x31];
[ 5, 0x2b, 0x30, 0x39, 0xd4, 0x31];
expect(sock).to.have.sent(new Uint8Array(expected));
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The masking should probably be tested as an explicitly different test.

Instead of keeping track of button states ourselves by looking at
MouseEvent.button, we can use the MouseEvent.buttons which already
contains the state of all buttons.
This commit implements the extendedMouseButtons pseudo-encoding, which
makes it possible to use the forward and back mouse buttons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants